<?php

namespace app\index\controller;

use think\Controller;
use think\Request;
use think\Db;
use think\Session;

class Mood extends Controller
{
    /**
     * 心情随笔 导航栏
     *
     * @return \think\Response
     */
    public function index()
    {
        //登录处理
        $info = Session::get('user_info');

        $user_id = $info['user_id'];
        $art = Db::name('artcomment')->where('user_id', $user_id)->select();
        $posts = Db::name('post')->where('user_id', $user_id)->select();

        $list = Db::name('article')->field('artname,arttime,artcontent')->where('column_id',3)->select();

        $love = Db::name('article')->limit(4)->order('artlove desc')->select();
        $datas = array();
        foreach($love as $v){
            $colname_hot = Db::name('column')->field('colname')->where('column_id',$v['column_id'])->find();
            $v['colname_hot'] = $colname_hot;
            $datas[] = $v;

        }

        $links = Db::name('links')->select();

        return view('mood/index',[
            'lists'=>$list,
            'love'=>$datas,
            'links'=>$links,
            'user_id' => $info['user_id'],
            'username' => $info['username'],
            'sex' => $info['sex'],
            'age' => $info['age'],
            'userpic' => $info['userpic'],
            'tel' => $info['tel'],
            'email' => $info['email'],
            'integral' => $info['bp'],
            'list' => $art,
            'posts' => $posts
        ]);
    }

}
